<?php

class Control_Model_Table_Settings extends Zend_Db_Table_Abstract
{
    protected $_name = 'settings';
    
    public function getCopyright()
    {   $val = 'copyright';
        $select = $this->select();
        $select->order('id DESC')
               ->where('type=?',$val)
               ->limit('1');
        $CopyRight = $this->_db->query($select)->fetchAll();
        $CopyRight = $CopyRight['0']['params'];
        return $CopyRight;
    }

        public function getDayQuote()
    {   $val = 'day_quote';
        $select = $this->select();
        $select->order('id DESC')
               ->where('type=?',$val)
               ->limit('1');
        $DayQuote = $this->_db->query($select)->fetchAll();
        $DayQuote = $DayQuote['0']['text'];
        return $DayQuote;
    }

            public function getAdvertise()
    {   $val = 'advertise';
        $select = $this->select();
        $select->order('id DESC')
               ->where('type=?',$val)
               ->limit('1');
        $adv = $this->_db->query($select)->fetchAll();
        $adv=$adv[0];
        return $adv;
    }

        public function getAll()
    {
        $select = $this->select();
        $select->order('id DESC');
        $Data = $this->_db->query($select)->fetchAll();
        return $Data;
    }

        public function updateDataServices($title, $text1, $author_text, $text3, $author)
    {
        $data = array(
            'title' => $title,
            'text1' => $text1,
            'author_text' => $author_text,
            'text3' => $text3,
            'author' => $author
        );
        $this->update($data,'id= '.'1');
    }

            public function updateSettings($day_quote, $advertise_link, $advertise_img, $copyright)
    {
        $data = array(
            'params' => $copyright
        );
        $this->update($data,'id= '.'1');
        $data = array(
            'text' => $day_quote
        );
        $this->update($data,'id= '.'2');
        $data = array(
            'res' => $advertise_link,
            'params' => $advertise_img
        );
        $this->update($data,'id= '.'3');
    }

}

